home *** CD-ROM | disk | FTP | other *** search
- /*
- ==============================================================================
-
- BOSS MECH
-
- ==============================================================================
- */
-
- #include "g_local.h"
- #include "M_bigmech.h"
-
-
- void boss_doattack_rocket (edict_t *self);
-
- static int sound_thud;
- static int sound_pain;
- static int sound_idle;
- static int sound_die;
- static int sound_step;
- static int sound_sight;
- static int sound_windup;
- static int sound_strike;
- static int sound_fire;
-
- //
- // misc
- //
-
- void boss_sight (edict_t *self, edict_t *other)
- {
- gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
- }
-
- void boss_stomp_right (edict_t *self)
- {
- int i;
- edict_t *e;
- vec3_t forward, right;
- vec3_t start;
-
- for (i=1, e=g_edicts+i; i < globals.num_edicts; i++,e++)
- {
- if (!e->inuse)
- continue;
- if (!e->client)
- continue;
- if (!e->groundentity)
- continue;
-
- e->groundentity = NULL;
- e->velocity[0] += crandom()* 50;
- e->velocity[1] += crandom()* 50;
- e->velocity[2] += crandom()* 100;
- }
-
- AngleVectors (self->s.angles, forward, right, NULL);
- VectorCopy (self->s.origin, start);
-
- //start[2] = start[2] - 16;
-
- right[0] = right[0] * 25;
- right[1] = right[1] * 25;
- forward[0] = forward[0] * 10;
- forward[1] = forward[1] * 10;
-
- VectorAdd(start, forward, start);
- VectorAdd(start, right, start);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION2);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
- }
-
- void boss_stomp_left (edict_t *self)
- {
- int i;
- edict_t *e;
- vec3_t forward, right;
- vec3_t start;
-
- for (i=1, e=g_edicts+i; i < globals.num_edicts; i++,e++)
- {
- if (!e->inuse)
- continue;
- if (!e->client)
- continue;
- if (!e->groundentity)
- continue;
-
- e->groundentity = NULL;
- e->velocity[0] += crandom()* 50;
- e->velocity[1] += crandom()* 50;
- e->velocity[2] += crandom()* 100;
- }
-
- AngleVectors (self->s.angles, forward, right, NULL);
- VectorCopy (self->s.origin, start);
-
- // start[2] = start[2] - 16;
-
- right[0] = right[0] * -25;
- right[1] = right[1] * -25;
-
- forward[0] = forward[0] * 10;
- forward[1] = forward[1] * 10;
-
- VectorAdd(start, forward, start);
-
- VectorAdd(start, right, start);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION2);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
- }
-
- void boss_thud (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_thud, 1, ATTN_NORM, 0);
- }
-
- void boss_windup (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_windup, 1, ATTN_NORM, 0);
- }
-
- void boss_idle (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
- }
-
-
- //
- // stand
- //
-
- mframe_t boss_frames_stand []=
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- };
- mmove_t boss_move_stand = {FRAME_shoot01, FRAME_shoot07, boss_frames_stand, NULL};
-
- void boss_stand (edict_t *self)
- {
- self->monsterinfo.currentmove = &boss_move_stand;
- }
-
-
- //
- // walk
- //
-
- void boss_walk (edict_t *self);
-
-
- mframe_t boss_frames_walk [] =
- {
- ai_walk, 14, boss_stomp_left,
- ai_walk, 15, NULL,
- ai_walk, 13, NULL,
- ai_walk, 12, NULL,
- ai_walk, 0, NULL,
- ai_walk, 0, NULL,
- ai_walk, 0, boss_stomp_right,
- ai_walk, 13, NULL,
- ai_walk, 15, NULL,
- ai_walk, 17, NULL,
- ai_walk, 0, NULL,
- ai_walk, 0, NULL
- };
- mmove_t boss_move_walk = {FRAME_walk01, FRAME_walk12, boss_frames_walk, NULL};
-
- void boss_walk (edict_t *self)
- {
- self->monsterinfo.currentmove = &boss_move_walk;
- }
-
-
- //
- // run
- //
-
- void boss_run (edict_t *self);
-
- mframe_t boss_frames_run [] =
- {
- ai_run, 14, boss_stomp_left,
- ai_run, 15, NULL,
- ai_run, 13, NULL,
- ai_run, 12, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, boss_stomp_right,
- ai_run, 13, NULL,
- ai_run, 15, NULL,
- ai_run, 17, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL
- };
- mmove_t boss_move_run = {FRAME_walk01, FRAME_walk12, boss_frames_run, NULL};
-
- void boss_run (edict_t *self)
- {
- if (self->enemy && self->enemy->client)
- self->monsterinfo.aiflags |= AI_BRUTAL;
- else
- self->monsterinfo.aiflags &= ~AI_BRUTAL;
-
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- {
- self->monsterinfo.currentmove = &boss_move_stand;
- return;
- }
-
- self->monsterinfo.currentmove = &boss_move_run;
- }
-
- //
- // pain
- //
-
- mframe_t boss_frames_pain1 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t boss_move_pain1 = {FRAME_shoot01, FRAME_shoot04, boss_frames_pain1, boss_run};
-
- mframe_t boss_frames_pain2 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t boss_move_pain2 = {FRAME_shoot01, FRAME_shoot05, boss_frames_pain2, boss_run};
-
- mframe_t boss_frames_pain3 [] =
- {
- ai_move, -7, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 2, NULL,
- ai_move, 0, NULL,
- };
- mmove_t boss_move_pain3 = {FRAME_shoot01, FRAME_shoot06, boss_frames_pain3, boss_run};
-
-
- void boss_pain (edict_t *self, edict_t *other, float kick, int damage)
- {
- if (self->health < (self->max_health / 2))
- self->s.skinnum |= 1;
-
- if (damage <= 10)
- return;
-
- if (level.time < self->pain_debounce_time)
- return;
-
- if (damage <= 30)
- if (random() > 0.2)
- return;
-
- // If hard or nightmare, don't go into pain while attacking
-
- self->pain_debounce_time = level.time + 3;
- gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
-
- if (damage <= 30)
- self->monsterinfo.currentmove = &boss_move_pain1;
- else if (damage <= 60)
- self->monsterinfo.currentmove = &boss_move_pain2;
- else
- self->monsterinfo.currentmove = &boss_move_pain3;
- }
-
-
- //
- // attacks
- //
-
- void bossStrike (edict_t *self)
- {
- gi.sound (self, CHAN_WEAPON, sound_strike, 1, ATTN_NORM, 0);
- }
-
- void bossRocket1 (edict_t *self)
- {
- vec3_t forward, right;
- vec3_t start;
- vec3_t dir;
- vec3_t vec;
- int flash_number;
-
- flash_number = MZ2_TANK_ROCKET_3;
-
- AngleVectors (self->s.angles, forward, right, NULL);
-
- right[0] = right[0] * 2.7;
- right[1] = right[1] * 2.7;
-
- G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
-
- VectorCopy (self->enemy->s.origin, vec);
- vec[2] += self->enemy->viewheight;
- VectorSubtract (vec, start, dir);
- VectorNormalize (dir);
- start[2] = start[2] - 4;
- gi.sound (self, CHAN_VOICE, sound_fire, 1, ATTN_NORM, 0);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION1);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
-
- monster_fire_rocket (self, start, dir, 50, 550, flash_number);
- }
-
- void bossRocket2 (edict_t *self)
- {
- vec3_t forward, right;
- vec3_t start;
- vec3_t dir;
- vec3_t vec;
- int flash_number;
-
- flash_number = MZ2_TANK_ROCKET_3;
-
- AngleVectors (self->s.angles, forward, right, NULL);
-
- right[0] = right[0] * -2.7;
- right[1] = right[1] * -2.7;
-
- G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
-
- VectorCopy (self->enemy->s.origin, vec);
- vec[2] += self->enemy->viewheight;
- VectorSubtract (vec, start, dir);
- VectorNormalize (dir);
- start[2] = start[2] - 8;
- gi.sound (self, CHAN_VOICE, sound_fire, 1, ATTN_NORM, 0);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION1);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
-
- monster_fire_rocket (self, start, dir, 50, 550, flash_number);
- }
-
- mframe_t boss_frames_attack_fire_rocket [] =
- {
- ai_charge, -3, NULL, // Loop Start 22
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, bossRocket1,
- ai_charge, 0, bossRocket2,
- ai_charge, 0, NULL,
- ai_charge, -1, NULL // 30 Loop End
- };
- mmove_t boss_move_attack_fire_rocket = {FRAME_shoot01, FRAME_shoot07, boss_frames_attack_fire_rocket, boss_run};
-
- void boss_doattack_rocket (edict_t *self)
- {
- self->monsterinfo.currentmove = &boss_move_attack_fire_rocket;
- }
-
- void boss_attack (edict_t *self)
- {
- vec3_t vec;
- float range;
- float r;
-
- VectorSubtract (self->enemy->s.origin, self->s.origin, vec);
- range = VectorLength (vec);
-
- r = random();
-
- self->monsterinfo.currentmove = &boss_move_attack_fire_rocket;
- self->pain_debounce_time = level.time + 5.0; // no pain for a while
- }
-
-
- //
- // death
- //
-
- void boss_dead (edict_t *self)
- {
- VectorSet (self->mins, -16, -16, -56);
- VectorSet (self->maxs, 16, 16, -8);
- self->movetype = MOVETYPE_TOSS;
- self->svflags |= SVF_DEADMONSTER;
- self->nextthink = 0;
- gi.linkentity (self);
- }
-
- mframe_t boss_frames_death1 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t boss_move_death = {FRAME_shoot01, FRAME_shoot06, boss_frames_death1, boss_dead};
-
- void boss_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
- {
- int n, spd;
- vec3_t start, org;
-
- // tower of fire code here (will add body parts flying next)
- VectorCopy (self->s.origin, start);
- for (n = 1; n < 3; n++)
- {
- start[2] = start[2] + 64;
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION1);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
- }
-
- for (n = 0; n < 3; n++)
- {
- spd = 5;
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/gibs/bigmech_arm/tris.md2", spd, org);
- }
-
- ThrowHead (self, "models/objects/gibs/bigmech_bod/tris.md2", damage, GIB_METALLIC, EF_GIB);
-
- self->deadflag = DEAD_DEAD;
- self->takedamage = DAMAGE_NO;
- VectorSet (self->mins, -32, -32, 0);
- VectorSet (self->maxs, 32, 32, 8);
- self->movetype = MOVETYPE_TOSS;
- self->nextthink = 0;
- self->think = NULL;
- }
-
-
- //
- // monster_boss
- //
-
- /*QUAKED monster_boss (1 .5 0) (-32 -32 -16) (32 32 72) Ambush Trigger_Spawn Sight
- */
- /*QUAKED monster_boss_commander (1 .5 0) (-32 -32 -16) (32 32 72) Ambush Trigger_Spawn Sight
- */
- void SP_monster_bigmech (edict_t *self)
- {
- if (deathmatch->value)
- {
- G_FreeEdict (self);
- return;
- }
-
- self->s.modelindex = gi.modelindex ("models/monsters/bigmech/tris.md2");
- VectorSet (self->mins, -64, -64, 0);
- VectorSet (self->maxs, 64, 64, 128);
- self->movetype = MOVETYPE_STEP;
- self->solid = SOLID_BBOX;
-
- sound_pain = gi.soundindex ("robot9/move1.wav");
- sound_thud = gi.soundindex ("martian/step.wav");
- sound_idle = gi.soundindex ("robot9/mach.wav");
- sound_die = gi.soundindex ("martian/step.wav");
- sound_step = gi.soundindex ("robot9/servo2.wav");
- sound_windup = gi.soundindex ("robot9/servo2.wav");
- sound_strike = gi.soundindex ("robot9/mach.wav");
- sound_sight = gi.soundindex ("robot9/move3.wav");
- sound_fire = gi.soundindex ("weapons/rocklf1a.wav");
-
- gi.soundindex ("tank/tnkatck1.wav");
- gi.soundindex ("tank/tnkatk2a.wav");
- gi.soundindex ("tank/tnkatk2b.wav");
- gi.soundindex ("tank/tnkatk2c.wav");
- gi.soundindex ("tank/tnkatk2d.wav");
- gi.soundindex ("tank/tnkatk2e.wav");
- gi.soundindex ("tank/tnkatck3.wav");
-
- self->max_health = 750;
- self->health = self->max_health;
- self->gib_health = -200;
-
- self->mass = 500;
- self->classname = "monster_mech";
-
- self->pain = boss_pain;
- self->die = boss_die;
- self->monsterinfo.stand = boss_stand;
- self->monsterinfo.walk = boss_walk;
- self->monsterinfo.run = boss_run;
- self->monsterinfo.dodge = NULL;
- self->monsterinfo.attack = boss_attack;
- self->monsterinfo.melee = NULL;
- self->monsterinfo.sight = boss_sight;
- self->monsterinfo.idle = boss_idle;
-
- gi.linkentity (self);
-
- self->monsterinfo.currentmove = &boss_move_stand;
- self->monsterinfo.scale = MODEL_SCALE;
-
- walkmonster_start (self);
- }
-